import { defineConfig } from "vite";
import AutoImport from "unplugin-auto-import/vite";
import Components from "unplugin-vue-components/vite";
import { ElementPlusResolver } from "unplugin-vue-components/resolvers";
import vue from "@vitejs/plugin-vue";
import { VantResolver } from '@vant/auto-import-resolver';

export default defineConfig({
  plugins: [
    vue(),
    AutoImport({
      resolvers: [ElementPlusResolver()],
      imports: ["vue"],
      dts: "src/auto-import.d.ts",
    }),
    Components({
      resolvers: [ElementPlusResolver(), VantResolver()],
    }),
  ],
  //全局引入样式
  css: {
    preprocessorOptions: {
      scss: {
        additionalData: "@import './src/style/base.scss';",
      },
    },
  },
  server: {
    host: "0.0.0.0",
    port: 3030, //启动端口
    //代理地址
    proxy: {
      "/api": {
        target: 'https://yxzc.edtzk.com/',
        // target: "http://192.168.0.151:1000/",
        // target: "https://baike.baidu.com/item/",
        ws: true,
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, ""),
      },

    },
  },
});
